package com.wyy.dao.impl;

import com.wyy.bean.Grade;
import com.wyy.dao.DBUtils;
import com.wyy.dao.GradeDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName GradeDaoImpl
 * @Description //TODO
 * @Author wky
 * @Date 2021/9/12 14:52
 * @Version 1.0
 **/
public class GradeDaoImpl extends DBUtils implements GradeDao {
    
    @Override
    public List<Grade> getList() {
        List<Grade> grades = new ArrayList<>();
        try {
            String sql = "select * from grade";
            resultSet = query(sql, null);
            while (resultSet.next()){
                Grade grade = new Grade();
                grade.setGradeId(resultSet.getInt("gradeid"));
                grade.setGradeName(resultSet.getString("gradename"));
                grades.add(grade);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            closeAll();
        }
        return grades;
    }
}
